package com.facebook.imagepipeline.producers;

import com.facebook.cache.common.CacheKey;
import com.facebook.common.internal.ImmutableMap;
import com.facebook.common.internal.VisibleForTesting;
import com.facebook.common.references.CloseableReference;
import com.facebook.imagepipeline.cache.CacheKeyFactory;
import com.facebook.imagepipeline.cache.MemoryCache;
import com.facebook.imagepipeline.image.EncodedImage;
import com.facebook.imagepipeline.memory.PooledByteBuffer;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequest.RequestLevel;
import java.util.Map;

public class EncodedMemoryCacheProducer
  implements Producer<EncodedImage>
{

  @VisibleForTesting
  static final String PRODUCER_NAME = "EncodedMemoryCacheProducer";

  @VisibleForTesting
  static final String VALUE_FOUND = "cached_value_found";
  private final CacheKeyFactory mCacheKeyFactory;
  private final Producer<EncodedImage> mInputProducer;
  private final MemoryCache<CacheKey, PooledByteBuffer> mMemoryCache;

  public EncodedMemoryCacheProducer(MemoryCache<CacheKey, PooledByteBuffer> paramMemoryCache, CacheKeyFactory paramCacheKeyFactory, Producer<EncodedImage> paramProducer)
  {
    this.mMemoryCache = paramMemoryCache;
    this.mCacheKeyFactory = paramCacheKeyFactory;
    this.mInputProducer = paramProducer;
  }

  public void produceResults(Consumer<EncodedImage> paramConsumer, ProducerContext paramProducerContext)
  {
    String str = paramProducerContext.getId();
    ProducerListener localProducerListener = paramProducerContext.getListener();
    localProducerListener.onProducerStart(str, "EncodedMemoryCacheProducer");
    ImageRequest localImageRequest = paramProducerContext.getImageRequest();
    final CacheKey localCacheKey = this.mCacheKeyFactory.getEncodedCacheKey(localImageRequest, paramProducerContext.getCallerContext());
    CloseableReference localCloseableReference = this.mMemoryCache.get(localCacheKey);
    if (localCloseableReference != null)
      try
      {
        EncodedImage localEncodedImage = new EncodedImage(localCloseableReference);
        try
        {
          boolean bool3 = localProducerListener.requiresExtraMap(str);
          Map localMap3 = null;
          if (bool3)
            localMap3 = ImmutableMap.of("cached_value_found", "true");
          localProducerListener.onProducerFinishWithSuccess(str, "EncodedMemoryCacheProducer", localMap3);
          paramConsumer.onProgressUpdate(1.0F);
          paramConsumer.onNewResult(localEncodedImage, true);
          return;
        }
        finally
        {
        }
      }
      finally
      {
        CloseableReference.closeSafely(localCloseableReference);
      }
    if (paramProducerContext.getLowestPermittedRequestLevel().getValue() >= ImageRequest.RequestLevel.ENCODED_MEMORY_CACHE.getValue())
    {
      boolean bool2 = localProducerListener.requiresExtraMap(str);
      Map localMap2 = null;
      if (bool2)
        localMap2 = ImmutableMap.of("cached_value_found", "false");
      localProducerListener.onProducerFinishWithSuccess(str, "EncodedMemoryCacheProducer", localMap2);
      paramConsumer.onNewResult(null, true);
      CloseableReference.closeSafely(localCloseableReference);
      return;
    }
    DelegatingConsumer local1 = new DelegatingConsumer(paramConsumer)
    {
      // ERROR //
      public void onNewResultImpl(EncodedImage paramAnonymousEncodedImage, boolean paramAnonymousBoolean)
      {
        // Byte code:
        //   0: iload_2
        //   1: ifeq +7 -> 8
        //   4: aload_1
        //   5: ifnonnull +15 -> 20
        //   8: aload_0
        //   9: invokevirtual 29	com/facebook/imagepipeline/producers/EncodedMemoryCacheProducer$1:getConsumer	()Lcom/facebook/imagepipeline/producers/Consumer;
        //   12: aload_1
        //   13: iload_2
        //   14: invokeinterface 35 3 0
        //   19: return
        //   20: aload_1
        //   21: invokevirtual 41	com/facebook/imagepipeline/image/EncodedImage:getByteBufferRef	()Lcom/facebook/common/references/CloseableReference;
        //   24: astore_3
        //   25: aload_3
        //   26: ifnull +110 -> 136
        //   29: aload_0
        //   30: getfield 18	com/facebook/imagepipeline/producers/EncodedMemoryCacheProducer$1:this$0	Lcom/facebook/imagepipeline/producers/EncodedMemoryCacheProducer;
        //   33: invokestatic 45	com/facebook/imagepipeline/producers/EncodedMemoryCacheProducer:access$000	(Lcom/facebook/imagepipeline/producers/EncodedMemoryCacheProducer;)Lcom/facebook/imagepipeline/cache/MemoryCache;
        //   36: aload_0
        //   37: getfield 20	com/facebook/imagepipeline/producers/EncodedMemoryCacheProducer$1:val$cacheKey	Lcom/facebook/cache/common/CacheKey;
        //   40: aload_3
        //   41: invokeinterface 51 3 0
        //   46: astore 5
        //   48: aload_3
        //   49: invokestatic 57	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
        //   52: aload 5
        //   54: ifnull +82 -> 136
        //   57: new 37	com/facebook/imagepipeline/image/EncodedImage
        //   60: dup
        //   61: aload 5
        //   63: invokespecial 59	com/facebook/imagepipeline/image/EncodedImage:<init>	(Lcom/facebook/common/references/CloseableReference;)V
        //   66: astore 6
        //   68: aload 6
        //   70: aload_1
        //   71: invokevirtual 63	com/facebook/imagepipeline/image/EncodedImage:copyMetaDataFrom	(Lcom/facebook/imagepipeline/image/EncodedImage;)V
        //   74: aload 5
        //   76: invokestatic 57	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
        //   79: aload_0
        //   80: invokevirtual 29	com/facebook/imagepipeline/producers/EncodedMemoryCacheProducer$1:getConsumer	()Lcom/facebook/imagepipeline/producers/Consumer;
        //   83: fconst_1
        //   84: invokeinterface 67 2 0
        //   89: aload_0
        //   90: invokevirtual 29	com/facebook/imagepipeline/producers/EncodedMemoryCacheProducer$1:getConsumer	()Lcom/facebook/imagepipeline/producers/Consumer;
        //   93: aload 6
        //   95: iconst_1
        //   96: invokeinterface 35 3 0
        //   101: aload 6
        //   103: invokestatic 69	com/facebook/imagepipeline/image/EncodedImage:closeSafely	(Lcom/facebook/imagepipeline/image/EncodedImage;)V
        //   106: return
        //   107: astore 4
        //   109: aload_3
        //   110: invokestatic 57	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
        //   113: aload 4
        //   115: athrow
        //   116: astore 7
        //   118: aload 5
        //   120: invokestatic 57	com/facebook/common/references/CloseableReference:closeSafely	(Lcom/facebook/common/references/CloseableReference;)V
        //   123: aload 7
        //   125: athrow
        //   126: astore 8
        //   128: aload 6
        //   130: invokestatic 69	com/facebook/imagepipeline/image/EncodedImage:closeSafely	(Lcom/facebook/imagepipeline/image/EncodedImage;)V
        //   133: aload 8
        //   135: athrow
        //   136: aload_0
        //   137: invokevirtual 29	com/facebook/imagepipeline/producers/EncodedMemoryCacheProducer$1:getConsumer	()Lcom/facebook/imagepipeline/producers/Consumer;
        //   140: aload_1
        //   141: iconst_1
        //   142: invokeinterface 35 3 0
        //   147: return
        //
        // Exception table:
        //   from	to	target	type
        //   29	48	107	finally
        //   57	74	116	finally
        //   79	101	126	finally
      }
    };
    boolean bool1 = localProducerListener.requiresExtraMap(str);
    Map localMap1 = null;
    if (bool1)
      localMap1 = ImmutableMap.of("cached_value_found", "false");
    localProducerListener.onProducerFinishWithSuccess(str, "EncodedMemoryCacheProducer", localMap1);
    this.mInputProducer.produceResults(local1, paramProducerContext);
    CloseableReference.closeSafely(localCloseableReference);
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.facebook.imagepipeline.producers.EncodedMemoryCacheProducer
 * JD-Core Version:    0.6.2
 */